package promote.brozen.base.stream;

import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Map;
import java.util.function.BinaryOperator;
import java.util.stream.Collectors;

/**
 * @author Brozen
 * @date 2020/8/14 9:08 AM
 * @email brozen@qq.com
 */
public class ToMapRepeat {

    public static void main(String[] args) {
        List<String> array = new ArrayList<>();
        array.add("123");
        array.add("456");

        Map<Integer, String> map = array.stream()
                .collect(Collectors.toMap(s -> (Integer) s.length(), s -> s, BinaryOperator.minBy(Comparator.<String>naturalOrder())));
        System.out.println(map);
    }

}
